package com.goodwill.androidtest.threadtest;

public class ThreadB extends Thread {

    private Object lock;

    public ThreadB(Object lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        super.run();

        synchronized (lock) {
            for (int i = 1; i <= 10; i++) {
                System.out.println("notify begin: " + Thread.currentThread().getName() + "value:" + i);
                if (MyList.size() == 5) {
                    MyList.add(String.valueOf(i));
                    lock.notify();
                    System.out.println("发送唤醒通知");
                }
                System.out.println("notify end: " + Thread.currentThread().getName() + "value:" + i);
            }
        }
    }
}
